Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Imaging with QuickDraw

Previous | Chapter Top | Chapter Contents | Next |

Creating, Setting, and Disposing of Pixel Maps

QuickDraw automatically creates pixel maps when you create a color window with the GetNewCWindow or NewCWindow function (described in the chapter "Window Manager" in Inside Macintosh: Macintosh Toolbox Essentials ), when you create offscreen graphics worlds with the NewGWorld function (described in the chapter "Offscreen Graphics Worlds" in this book), and when you use the OpenCPort function. QuickDraw also disposes of a pixel map when it disposes of a color graphics port. Although your application typically won't need to create or dispose of pixel maps, you can use the NewPixMap function and the CopyPixMap procedure to create them, and you can use the DisposePixMap procedure to dispose of them. Although you should never need to do so, you can also set the pixel map for the current color graphics port by using the SetPortPix procedure.

NewPixMap

Although you typically don't need to call this routine in your application code, you can use the NewPixMap function to create a new, initialized PixMap record.

FUNCTION NewPixMap: PixMapHandle;

DESCRIPTION

The NewPixMap function creates a new, initialized PixMap record and returns a handle to it. All fields of the PixMap record are copied from the current device's PixMap record except the color table. In System 7, the hRes and vRes fields are set to 72 dpi, no matter what values the current device's PixMap record contains. A handle to the color table is allocated but not initialized.

You typically don't need to call this routine. PixMap records are created for you when you create a window using the Window Manager functions NewCWindow and GetNewCWindow and when you create an offscreen graphics world with the NewGWorld function.

If your application creates a pixel map, your application must initialize the PixMap record's color table to describe the pixels. You can use the GetCTable function (described on GetCTable ) to read such a table from a resource file; you can then use the DisposeCTable procedure (described on DisposeCTable ) to dispose of the PixMap record's color table and replace it with the one returned by GetCTable .

SPECIAL CONSIDERATIONS

The NewPixMap function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.

CopyPixMap

Although you typically don't need to call this routine in your application code, you can use the CopyPixMap procedure to duplicate a PixMap record.

PROCEDURE CopyPixMap (srcPM,dstPM: PixMapHandle);
srcPM
A handle to the PixMap record to be copied.
dstPM
A handle to the duplicated PixMap record.

DESCRIPTION

The CopyPixMap procedure copies the contents of the source PixMap record to the destination PixMap record. The contents of the color table are copied, so the destination PixMap has its own copy of the color table. Because the baseAddr field of the PixMap record is a pointer, the pointer, but not the image itself, is copied.

SetPortPix

Although you should never need to do so, you can set the pixel map for the current color graphics port by using the SetPortPix procedure.

PROCEDURE SetPortPix (pm: PixMapHandle);
pm
A handle to the PixMap record.

DESCRIPTION

The SetPortPix procedure replaces the portPixMap field of the current CGrafPort record with the handle you specify in the pm parameter.

SPECIAL CONSIDERATIONS

The SetPortPix procedure is analogous to the basic QuickDraw procedure SetPortBits , which sets the bitmap for the current basic graphics port. The  SetPortPix procedure has no effect when used with a basic graphics port. Similarly, SetPortBits has no effect when used with a color graphics port.

Both SetPortPix and SetPortBits allow you to perform drawing and calculations on a buffer other than the screen. However, instead of using these procedures, you should use the offscreen graphics capabilities described in the chapter "Offscreen Graphics Worlds."

DisposePixMap

Although you typically don't need to call this routine in your application code, you can use the DisposePixMap procedure to dispose of a PixMap record. The DisposePixMap procedure is also available as the DisposPixMap procedure.

PROCEDURE DisposePixMap (pm: PixMapHandle);
pm
A handle to the PixMap record to be disposed of.

DESCRIPTION

The DisposePixMap procedure disposes of the PixMap record and its color table. The CloseCPort procedure calls DisposePixMap .

SPECIAL CONSIDERATIONS

If your application uses DisposePixMap , take care that it does not dispose of a PixMap record whose color table is the same as the current device's CLUT.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next